package com.ambulance.project.biz.controller.manager;

import com.ambulance.common.utils.poi.ExcelUtil;
import com.ambulance.framework.aspectj.lang.annotation.Log;
import com.ambulance.framework.aspectj.lang.enums.BusinessType;
import com.ambulance.framework.web.controller.BaseController;
import com.ambulance.framework.web.domain.AjaxResult;
import com.ambulance.framework.web.page.TableDataInfo;
import com.ambulance.project.manager.domain.BizDispatcher;
import com.ambulance.project.manager.service.IBizDispatcherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 调度员管理Controller
 *
 * @author zr
 * @date 2020-05-11
 */
@RestController
@RequestMapping("/manager/dispatcher")
public class BizDispatcherController extends BaseController {
    @Autowired
    private IBizDispatcherService bizDispatcherService;

    /**
     * 查询调度员管理列表
     */
    //@PreAuthorize("@ss.hasPermi('manager:dispatcher:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizDispatcher bizDispatcher) {
        startPage();
        List<BizDispatcher> list = bizDispatcherService.selectBizDispatcherList(bizDispatcher);
        return getDataTable(list);
    }

    /**
     * 导出调度员管理列表
     */
    //@PreAuthorize("@ss.hasPermi('manager:dispatcher:export')")
    @Log(title = "调度员管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BizDispatcher bizDispatcher) {
        List<BizDispatcher> list = bizDispatcherService.selectBizDispatcherList(bizDispatcher);
        ExcelUtil<BizDispatcher> util = new ExcelUtil<BizDispatcher>(BizDispatcher.class);
        return util.exportExcel(list, "dispatcher");
    }

    /**
     * 获取调度员管理详细信息
     */
    //@PreAuthorize("@ss.hasPermi('manager:dispatcher:query')")
    @GetMapping(value = "/{dispatcherID}")
    public AjaxResult getInfo(@PathVariable("dispatcherID") Long dispatcherID) {
        return AjaxResult.success(bizDispatcherService.selectBizDispatcherById(dispatcherID));
    }

    /**
     * 新增调度员管理
     */
    //@PreAuthorize("@ss.hasPermi('manager:dispatcher:add')")
    @Log(title = "调度员管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizDispatcher bizDispatcher) {

        return toAjax(bizDispatcherService.insertBizDispatcher(bizDispatcher));
    }


    /**
     * 修改调度员管理
     */
    //@PreAuthorize("@ss.hasPermi('manager:dispatcher:edit')")
    @Log(title = "调度员管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizDispatcher bizDispatcher) {
        return toAjax(bizDispatcherService.updateBizDispatcher(bizDispatcher));
    }

    /**
     * 删除调度员管理
     */
    //@PreAuthorize("@ss.hasPermi('manager:dispatcher:remove')")
    @Log(title = "调度员管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{dispatcherIDs}")
    public AjaxResult remove(@PathVariable Long[] dispatcherIDs) {
        return toAjax(bizDispatcherService.deleteBizDispatcherByIds(dispatcherIDs));
    }
}
